#include "mwin.h"
#include "ui_mwin.h"
#include "mdmethods.h"
#include <QDebug>

Mwin::Mwin(QList<Method*> *lmd,QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Mwin)
{
    ui->setupUi(this);
    this->wlmd=lmd;
    this->ui->action_Elemets->setChecked(true);
    this->ui->action_Pre->setChecked(true);

    connect(this->ui->action_Methods,SIGNAL(triggered()),SLOT(slot_onlibmethod()));
    connect(this->ui->action_Elemets,SIGNAL(triggered(bool)),SLOT(slot_onActElements(bool)));
    connect(this->ui->dw_nodelist,SIGNAL(visibilityChanged(bool)),SLOT(slot_onActElementsdw(bool)));
    connect(this->ui->action_Pre,SIGNAL(triggered(bool)),SLOT(slot_onActPre(bool)));
    connect(this->ui->dw_pre,SIGNAL(visibilityChanged(bool)),SLOT(slot_onActPredw(bool)));
}

Mwin::~Mwin()
{
    delete ui;
}

void Mwin::changeEvent(QEvent *e)
{
    QMainWindow::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void Mwin::slot_onlibmethod(){
//show dialog methods
    //qDebug()<<"show methods =)";
    MDmethods dia(this->wlmd);
    if(dia.exec()){
        qDebug()<<"Dia ok";
    }else{
        qDebug()<<"Dia false";
    }
}

void Mwin::slot_onActElements(bool st){
    this->ui->dw_nodelist->setVisible(st);
}

void Mwin::slot_onActElementsdw(bool st){
    this->ui->action_Elemets->setChecked(st);
}

void Mwin::slot_onActPre(bool st){
    this->ui->dw_pre->setVisible(st);
}

void Mwin::slot_onActPredw(bool st){
    this->ui->action_Pre->setChecked(st);
}
